$(document).ready(function() {
   $(".ccm-remo-expand-content").each(function (e,v) {
      $(this).css("height", $(this).height());
   });
   $(".ccm-remo-expand-closed").next().hide();
   
   $(".ccm-remo-expand-title").click(function(event) {
      event.preventDefault();
      
      var id = $(this).attr("id");

      if ($(this).hasClass("ccm-remo-expand-open")) {
         $(this).removeClass("ccm-remo-expand-open");
         $(this).addClass("ccm-remo-expand-closed");               
      }
      else {
         $(this).addClass("ccm-remo-expand-open");
         $(this).removeClass("ccm-remo-expand-closed");  
      }

      var contentId = id.replace(/ccm-remo-expand-title-/,"ccm-remo-expand-content-");
      
      $("#"+contentId).slideToggle(parseInt($(this).attr("data-expander-speed")));
      
   });
      
   $(window).hashchange( function() {
      findHash();
   });
	
   function findHash(){
		var hash = window.location.hash.substr(1);
		var $remoExpandTitle = $("a[name="+hash+"]").parents(".ccm-remo-expand").find(".ccm-remo-expand-title");
		if ($remoExpandTitle.hasClass("ccm-remo-expand-closed")) {
			 $remoExpandTitle.trigger("click");
			 $('html,body').animate({scrollTop: $remoExpandTitle.offset().top},'slow', function() {
				var oldColor = $remoExpandTitle.css("background-color");
				$remoExpandTitle.animate({backgroundColor: '#C8E4F9'}, 400, function() {
				   $remoExpandTitle.animate({backgroundColor: oldColor}, 400);
				});
			 });
		}
	}
	
	findHash();
   
});